package com.zhiyou100.video.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import com.zhiyou100.video.dao.SpeakerDao;
import com.zhiyou100.video.model.Speaker;
@SuppressWarnings("all")
public class SpeakerDaoImpl extends HibernateDaoSupport implements SpeakerDao {

	
	@Override
	public List<Speaker> selectSpeaker(DetachedCriteria dc, Integer currentpage) {
		
		return (List<Speaker>) getHibernateTemplate().findByCriteria(dc, (currentpage-1)*5, 5);
		
	}

	@Override
	public Integer selectCount(DetachedCriteria dc) {
		return getHibernateTemplate().findByCriteria(dc).size();
	}

	@Override
	public void addSpeaker(Speaker speaker) {
		getHibernateTemplate().saveOrUpdate(speaker);;
	}

	@Override
	public void deletespeaker(Integer did) {
		Speaker speaker = getHibernateTemplate().get(Speaker.class, did);
		getHibernateTemplate().delete(speaker);
	}

	@Override
	public Speaker selectSpeakerManage(Integer id) {
		return getHibernateTemplate().get(Speaker.class,id);
	}

	

}
